
<%
/**
 *	$RCSfile: uploadfile.jsp,v $
 *	$Revision: 1.2 $
 *	$Date: 2003/04/12 15:14:59 $
 */
%>

<%@	page import="java.io.*,com.oreilly.servlet.multipart.*"
	errorPage=""
	contentType="text/html"
%>
				 

<%	/////////////////////////
	// Create the new message
	String sellerID="";
	boolean errors = false;
	String errorMessage = "error";	
	String uploadURL="";
	boolean doPost=false;
	
			doPost=true;
			
      MultipartParser mp = new MultipartParser(request, 60*1024*1024); // 60MB
      Part part;
      while ((part = mp.readNextPart()) != null) {
        String name = part.getName();
        if (part.isParam() && name.equals("sellerID")) {
          // it's a parameter part
          ParamPart paramPart = (ParamPart) part;
          sellerID = paramPart.getStringValue();          
        }
        else if (part.isFile()) {
          // it's a file part
          FilePart filePart = (FilePart) part;
          String fileName = filePart.getFileName();
          String path = getServletContext().getRealPath("index.jsp");
	  File tempFile = new File(path);

		String appPath = tempFile.getParent();
        	 String dirName=appPath +File.separator+sellerID;
			
          if (fileName != null) {
            // the part actually contained a file
             File dir = new File(dirName);
             if (!dir.exists()) dir.mkdirs();
            filePart.writeTo(dir);
	      uploadURL="http://www.yuanma.com.cn/upload/";
          }
   
        }
      }
	errorMessage="Upload File Ok";
%>

<HTML>

<head>
	<title>uploadfile</title>
	
</head>

<p>				 
<%= errorMessage %>			 
	
</html>
